<?php
class Model_StudentMessage extends CCMIS_Model {
    //Database student_message
	public function __construct(){
		parent::__construct();
                
        $this->load->database();
	}

    public function getById($id)
    {
        $sql = "SELECT * FROM student_message WHERE StudentMessageID = ?";
        $query =  $this->db->query($sql, $id);
        $result = $query->row_array();
        return $result;
    }

    public function add($memberIDOwner, $text, $status, $datetime, $messageThreadID)
    {
        $datetime = date_format(date_create($datetime), 'Y-m-d');

        $sql = 'INSERT INTO `student_message`(
        `StudentMemberIDMessageOwner`,
        `Text`,
        `StudentMessageStatus`,
        `StudentMessageStatusDateTime`,
        `MessageThreadID`,
        )
        VALUES (?, ?, ?, ?, ?)';

        $this->db->query($sql, array($memberIDOwner, $text, $status, $datetime, $messageThreadID));

        return $this->db->insert_id();
    }

}
